<template>
  <div id="meeting">  
  
  <el-form ref="form"  label-width="0px">  
    <el-row>

        <el-col :span="24" style="text-align: right;"> 
           <el-button type="primary" class="custom_color_button" style="margin-bottom:10px;" @click="num_but()">蜜贝设置</el-button>          
           <el-button type="primary" class="custom_color_button" style="margin-bottom:10px;" @click="go_but()">盲盒设置</el-button>      
        </el-col>
   
  </el-row>
  </el-form >

   <!-- 渲染数据list -->
   <meeting-list :datalist="datalist" @up_list_fun="list_fun"> </meeting-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

        <!-- 蜜贝设置 -->
    <el-dialog title="蜜贝设置" :visible.sync="num_mtk"  width="350px">
        <div style="width:100%;"> 

        <el-form ref="form"   label-width="70px" style="width:100%;">              
              <el-form-item label="" label-width="0px">
                    <el-input    v-model="num_mtk_form.number" placeholder="请输入蜜贝设置"></el-input>
              </el-form-item>                                  
            </el-form>

            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;"  @click="num_but_qr">确认</el-button>
            </div>

        </div> 
    </el-dialog>
   

      
  </div>
</template>

<script>
import MeetingList from '@/view/Activity/MeetingList'
export default {
  name: 'meeting',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        num_mtk:false,
        num_mtk_form:{
            number:'',
        }
       
    }
  },
 components:{
    MeetingList
  },
  created(){
     this.list_fun()
     this.num_fun()
  },
  mounted (){
    
  },
  methods: { 
     num_fun(){
           this.post("/blind_box/sweetCoin", {
  
	         }).then(res => {
              this.num_mtk_form.number =  res.result.sweet_coin

            
              //console.log(this.num_mtk_form.number)
              //console.log(res,"mb")
          })
      },
      list_fun(){
           this.post("/blind_box/listOfComplete", {
              page:this.page,
	         }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list
              for(let item of  this.datalist) {
                  for(let a of  item.address_info) {
                    if(a.state){
                      item.adss = a
                    }
                     
                  }
                 
              }
            console.log(this.datalist)
          })
      },
      num_but(){
          this.num_mtk = true
        
      },
      num_but_qr(){
           this.post("/blind_box/setSweetCoin", {
                  sweet_coin:this.num_mtk_form.number
                }).then(res => {
                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.num_mtk = false
                    this.num_fun()
                    }else {
                    this.open1(res.message,'warning')
                }

        })
      },
     go_but(){
        this.$router.push({
          path: '/index/setmeeting',
          query: {
            //name:row.name,
            // id:row.uid,
            // type:type,
            // typename:typename
          }
        })
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>

</style>
